package com._520it.crm.web.controller;

import com._520it.crm.domain.Product;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.ProductQueryObject;
import com._520it.crm.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by 呆 on 2017/10/3.
 */
@Controller
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private IProductService productService;
    @RequestMapping("")
    public String index(){
        return "product";
    }

    @RequestMapping("/list")
    @ResponseBody
    public PageResult list(ProductQueryObject qo){
         return productService.query(qo);
    }
    @RequestMapping("/selectAll")
    @ResponseBody
    public List<Product> selectAll( ){
        return productService.selectAll();
    }

    /**
     * 根据承保机构的id查询产品
     * @param orgId 承保机构id
     * @return
     */
    @RequestMapping("/selectByOrgId")
    @ResponseBody
    public List<Product> selectByOrgId(Long orgId ){
        return productService.selectByOrgId(orgId);
    }
    @RequestMapping("/")
    public String save(){
        return "";
    }

    /**
     * 根据承保机构的id查询产品
     * @param orderBillId  保单id
     * @return
     */
    @RequestMapping("/selectByOrderId")
    @ResponseBody
    public List<Product> selectByOrderId(Long orderBillId ){
        return productService.selectByOrderId(orderBillId);
    }
    /**
     * 根据产品id查询产品
     * @param id 产品id
     * @return
     */
    @RequestMapping("/selectOne")
    @ResponseBody
    public Product selectOne(Long id ){
        return productService.selectByPrimaryKey(id);
    }
}
